package com.doit.day02;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;

public class _01_列出名称空间下面的所有表 {
    public static void main(String[] args) throws IOException {
        Configuration conf = HBaseConfiguration.create();
        //设置参数，给他一个zookeeper的集群地址
        conf.set("hbase.zookeeper.quorum","linux01:2181,linux02:2181,linux03:2181");
        //关于hbase的连接
        Connection conn = ConnectionFactory.createConnection(conf);
        //获取到操作对象
        Admin admin = conn.getAdmin();
        //调用api操作
        TableName[] tables = admin.listTableNamesByNamespace("doit");

        for (TableName table : tables) {
            //获取到表名称
            byte[] name = table.getName();
            String tableName = new String(name);
            System.out.println(tableName);
        }
        //关闭资源
        admin.close();
    }





}
